package com.solome.ui;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Disposable;
import com.solome.util.FontFactory;

public class SoLableTTF extends UiBaseMethod implements Disposable {
	private int fontSize;
	private String font;
	private boolean isWrapped;
	private float fontScale;

	public SoLableTTF(CharSequence font, int fontSize, Color color) {
		FontFactory.getInstance().init(font.toString(), fontSize);
		this.fontSize = fontSize;
		this.setColor(color);
		this.font = font.toString();
	}

	@Override
	public void draw(Batch batch, float parentAlpha) {
		// TODO Auto-generated method stub
		BitmapFont bitmapFont = getBitmapFont();
		if (bitmapFont == null) {
			return;
		}
		super.draw(batch, parentAlpha);
		bitmapFont.getCache().setColor(this.getColor());
		if (!isWrapped)
			bitmapFont.draw(batch, this.font, getX(bitmapFont.getSpaceWidth()
					* this.font.length()), getY(bitmapFont.getCapHeight()));
		else
			bitmapFont.draw(batch, this.font, getX(), getY(),
					Gdx.graphics.getWidth(), Align.center, true);
	}

	public BitmapFont getBitmapFont() {
		return FontFactory.getInstance().getFont(fontSize);
	}

	public String getFont() {
		return font;
	}

	public void setFont(String font) {
		this.font = font;
	}

	public boolean isWrapped() {
		return isWrapped;
	}

	public void setWrapped(boolean isWrapped) {
		this.isWrapped = isWrapped;
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
	}

	public float getFontScale() {
		return fontScale;
	}

	public void setFontScale(float scale) {
		this.fontScale = scale;
	}

}
